package org.komarichin.beans.service;

import org.komarichin.beans.ILanguage;
import org.komarichin.beans.IPartition;

import java.io.Serializable;
import java.util.Collection;

/**
 * User: Mykhaylo Komarichyn
 * Date: 16.12.2009
 * Time: 14:33:33
 */
public interface IPartitionService<PK> extends Serializable {
    /**
     * save partition
     *
     * @param partition saving partition
     * @return saved partition
     */
    IPartition<PK> save(IPartition<PK> partition);

    /**
     * @param partition partition for saveOrUpdate
     */
    void saveOrUpdate(IPartition<PK> partition);

    /**
     * @param partition partition for remove
     */
    void remove(IPartition<PK> partition);

    /**
     * @param id partition's id for remove
     */
    void remove(PK id);

    /**
     * @param id partition's id
     * @return found partition or null
     */
    IPartition<PK> findById(PK id);

    /**
     * @return all partitions
     */
    Collection<IPartition<PK>> getAll();

    /**
     * @param start     start result
     * @param limit     max returned result in query
     * @param fieldName field by sorting
     * @param order     sort order, true as asc, false as desc
     * @return result as news object by criteria
     */
    Collection<IPartition<PK>> getByCriteries(int start, int limit, String fieldName, boolean order);

    /**
     * @param lang language
     * @return collection of entity by language
     */
    Collection<IPartition<PK>> getAll(ILanguage lang);

    /**
     * @param lang      language
     * @param start     start result
     * @param limit     max returned result in query
     * @param fieldName field by sorting
     * @param order     sort order, true as asc, false as desc
     * @return result as news object by criteria
     */
    Collection<IPartition<PK>> getByCriteries(ILanguage lang, int start, int limit, String fieldName, boolean order);
}
